home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: analyzeTrans.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:55 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "volume.h"
- #include "openlog.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "util_funcs.h"
- #include "log_intfuncs.h"
- #include "log_extfuncs.h"
- #include "recover_intfuncs.h"
- #include "recover_extfuncs.h"
- #include "trans_extfuncs.h"
- #include "thread_globals.h"
- #include "trans_globals.h"
- #include "distr.h"
- #include "distr_globals.h"
-
-
- void
- analyzeTrans (
-
- register LOGRECORDHDR *record,
- register LSN *recordLSN
- )
- {
-
- register TRANSREC *transRec;
-
-
- TRPRINT(TR_LOG|TR_RECOVER, TR_LEVEL_1, ("recordLSN:%d tid:%x type:%d action:%d",
- recordLSN->offset, record->tid, record->type, record->action));
-
- /*
- * check to see if there is a transaction record
- */
- if ((transRec = findTransRec(record->tid)) == NULL) {
-
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("tid not found"));
-
- /*
- * allocate a transaction record
- */
- if ((transRec = allocRecoveryTrans()) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * hang the transaction off the hash table
- */
- listPush( &(TransHashTable[HASH_TID(record->tid)]), &(transRec->tidList) );
-
- /*
- * fill in the transaction information
- */
- transRec->tid = record->tid;
- transRec->firstLSN = *recordLSN;
- }
-
- /*
- * fill in the last lsn
- * Also fill in the first LSN if it is not already set. This
- * will be the case if the transaction had no log records
- * generated when the checkpoint was taken.
- */
- transRec->lastLSN = recordLSN->offset;
- if (transRec->firstLSN.offset == NULL_LSN) transRec->firstLSN = *recordLSN;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("lastLSN:%d", transRec->lastLSN));
-
- /*
- * check to see if the record is compensation or regular
- */
- switch (record->type) {
-
- case LOG_REC_TYPE_USER:
- case LOG_REC_TYPE_USER_COMPENSATION:
-
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("type user"));
-
- /*
- * check to see if the record is undoable
- */
- if (!(record->flags & REDO_ONLY)) {
-
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("not redo only: nextUndoLSN:%d", recordLSN->offset));
- transRec->nextUndoLSN = recordLSN->offset;
- }
- break;
-
- case LOG_REC_TYPE_COMPENSATION:
-
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("type compensation"));
-
- /*
- * fill in the next undo lsn
- */
- transRec->nextUndoLSN = record->nextUndoLSN;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("nextUndoLSN:%d", transRec->nextUndoLSN));
- /*
- * for distr trans - see if the trans is prepared
- * this would mean that this transaction was being
- * aborted - we don't expect any such records for
- * coord transactions though
- */
- if ((transRec->transState == T_PREPARED) &&
- (LIST_MEMBER(&(transRec->distrTransList)))) {
- /*
- * take it off the list of active distr transactions
- */
- listRemove( &(transRec->distrTransList) );
-
- /*
- * decrement the number of active distr transactions
- */
- numActiveServerDistrTrans--;
-
- /*
- * change the state back to recover so that
- * recoverUndo won't barf
- */
- transRec->transState = T_RECOVER;
- }
- break;
-
- default:
-
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("other record type"));
- break;
- }
- }
-